
#pragma once

#include "zadesk.h"
#include "zAdAChar.h"
#include "zAcCell.h"

#ifdef _ZSOFT_WINDOWS_
interface IUcSmDatabase;
interface IUcSmSheetSet;
interface IUcSmComponent;
struct UcHyperlink;
#endif

#ifdef  UCFD_API
#  define   UCFD_PORT  __declspec(dllexport)
#else
#  define   UCFD_PORT  
#endif

typedef ZSoft::UInt32 UcDbEvalNodeId;

namespace UcFdEval
{

    enum ObjectFieldOption
    {
        kObjFieldNone                   = 0,
        kObjFieldUnresolvedBlockRef     = (0x1 << 0),
        kObjFieldApplyBlockTransform    = (0x1 << 1),
        kObjFieldUnresolvedObjectRef    = (0x1 << 2),
    };

    enum SheetSetFieldOption
    {
        kSheetSetNone                   = 0,
        kSheetSetHyperlink              = (0x1 << 0),
        kSheetSetUnresolvedComponent    = (0x1 << 1),
    };

    enum ExpressionFieldOption
    {

        kExprFieldNone                  = 0,
        kExprFieldSum                   = (0x1 << 0),
        kExprFieldAverage               = (0x1 << 1),
        kExprFieldCount                 = (0x1 << 2),
        kExprFieldCell                  = (0x1 << 3),
        kExprFieldEquation              = (0x1 << 4),
    };
};

#ifdef _ZSOFT_WINDOWS_
UCFD_PORT BOOL   UcFdMakeFieldCode  (const UcDbObjectId& objId,
                                     UcDbEvalNodeId blockParamId,
                                     const ZTCHAR * pszPropOrCoectionName,
                                     UcFdEval::ObjectFieldOption nOption,
                                     const ZTCHAR * pszFormat,
                                     UcHyperlink* pHyperlink,
                                     ZTCHAR*& pszFieldCode);

UCFD_PORT BOOL   UcFdMakeFieldCode  (IUcSmDatabase* pSmDb,
                                     IUcSmSheetSet* pSmSheetSet,
                                     IUcSmComponent* pSmComp,
                                     const ZTCHAR * pszCompName,
                                     const ZTCHAR * pszPropName,
                                     UcFdEval::SheetSetFieldOption nOption,
                                     const ZTCHAR * pszFormat,
                                     ZTCHAR*& pszFieldCode);

UCFD_PORT BOOL   UcFdMakeFieldCode  (const UcDbObjectId& tableId,
                                     const UcDbObjectId& targetTableId,
                                     UcFdEval::ExpressionFieldOption nOption,
                                     const UcCellRangeArray& cellRanges,
                                     const ZTCHAR * pszFormat,
                                     UcHyperlink* pHyperlink,
                                     ZTCHAR*& pszFieldCode);

UCFD_PORT BOOL   UcFdExtractData    (UcDbField* pField,
                                     ZTCHAR *& pszSheetSetFile,
                                     ZTCHAR *& pszSheetSetId,
                                     ZTCHAR *& pszCompName,
                                     ZTCHAR *& pszCompId,
                                     ZTCHAR *& pszPropName);

UCFD_PORT BOOL   UcFdExtractData    (UcDbField* pField,
                                     UcDbObjectId& objId,
									 ZTCHAR *& pszPropName);
#endif

